﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZX.Web.UI.Controls;
using ZX.EHR.Library;
using ZX.SYS.Library;
using ZX.BLL.Extend;
using System.Data;

namespace ZX.WebApp.DeskTop.DeskTopItem
{
    public partial class hrReports : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //获取部门主管岗位
            DatDepartment dept = new DatDepartment();
            BaseBussnies deptbll = new BaseBussnies(dept);
            dept = deptbll.GetEntityById(this.EmpPropertyValues.DeptID.ToString()) as DatDepartment;
            if (dept.Manager.ToString() == this.EmpPropertyValues.PostID) //部门负责人
            {
                BaseBussnies bll = new BaseBussnies();
                string sql = "select deptname,EmpCount from dbo.fn_GetOrganizeEmpCount('" + this.EmpPropertyValues.DeptID.ToString() + "') where level=2 or level=1";
                DataTable dt = bll.GetDataBySqlComm(sql);
                var htmlTemp = "";
                //输出人数统计报表
                //htmlTemp += "<div>在职人员统计</div>";
                htmlTemp += "<div style='width:100%;height:100%;overflow:auto;'><link href='../../Styles/deskTopStyle.css' rel='stylesheet' type='text/css' /><table class='tableContent' cellspacing='0'>";
                htmlTemp += "<tr>";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var deptName = dt.Rows[i][0].ToString();
                    if (deptName.Contains("->"))
                    {
                        int index=deptName.LastIndexOf("->");
                        deptName = deptName.Substring(index + 2, deptName.Length - index - 2);
                    }
                    htmlTemp += "<th style='width:50px;'>" + deptName + "</th>";
                    if (i >= 17) break;
                }
                htmlTemp += "</tr><tr>";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    htmlTemp += "<td style='width:50px;'>" + dt.Rows[i][1].ToString() + "</td>";
                    if (i >= 17) break;
                }
                htmlTemp += "</tr>";
                htmlTemp += " </table>";
                //htmlTemp += " <br /><a style='font-size: 13px;' href=\"javascript:void(0)\" onclick=\"parent.ViewDeptChart()\">查看更多...</a></div>";

                Response.Clear();
                Response.Write(htmlTemp);
                Response.End();
            }
        }
    }
}